package com.yeswater.multithread.chapter2.test2_2.test3;

import java.util.concurrent.TimeUnit;

/**
 * author : yeswater
 * date : 2023/10/20
 */

public class Run {
    public static void main(String[] args) {
        Task task = new Task();
        Thread1 t1 = new Thread1(task);
        t1.start();
        Thread2 t2 = new Thread2(task);
        t2.start();

        try {
            TimeUnit.SECONDS.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        long beginTime = Math.min(CommonUtils.beginTime1, CommonUtils.beginTime2);
        long endTIme = Math.max(CommonUtils.endTime1, CommonUtils.endTime2);

        System.out.println("cost time : " + (endTIme - beginTime) / 1000);
    }
}
